<template>
  <div class="singer_wrap">
    <div
      v-for="(item, index) in singerList.slice(0, 3)"
      :key="index"
      class="item"
    >
      <div class="cover">
        <el-image
          lazy
          @click="toDetail(item.id)"
          :src="item.img1v1Url"
          fit="cover"
        ></el-image>
      </div>
      <div class="name">{{ item.name }}</div>
    </div>
  </div>
</template>

<script>
import { getSearchList } from "@/util/findMusic.js";
export default {
  name: "Searchsinger",

  data() {
    return {
      singerList: [],
    };
  },

  created() {
    this.getSearchList();
  },

  methods: {
    //获取搜素歌手
    async getSearchList() {
      let {
        data: {
          result: { artists },
        },
      } = await getSearchList(this.$route.params.keyword, 20, 0, 100);
      //   console.log(artists)
      if (artists) {
        this.singerList = artists;
      }
    },
    //跳转至歌手详情
    toDetail(id) {
      this.$router.push("/singerInfo/" + id);
    },
  },
};
</script>

<style lang="less" scoped>
.singer_wrap {
  margin-top: 20px;

  width: 100%;
  height: 100%;
  display: grid;
  justify-content: space-around;
  grid-template-columns: repeat(auto-fill, 13rem);
  .item {
    .cover {
      width: 12.375rem;
      height: 12.375rem;
      .el-image {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }
    .name {
      text-align: center;
      font-size: 18px;
      font-weight: 600;
      margin-top: 10px;
    }
  }
}
</style>